package com.swsc.solarverse.controller.openapi;


import com.swsc.solarverse.common.Constant;
import com.swsc.solarverse.common.enums.FaultCategoryEnum;
import com.swsc.solarverse.common.model.PageInfo;
import com.swsc.solarverse.model.RestResp;
import com.swsc.solarverse.model.req.DefectQueryReqVO;
import com.swsc.solarverse.model.res.OpenApiDefectLeDetailResVO;
import com.swsc.solarverse.model.res.StationDefectResVO;
import com.swsc.solarverse.service.openapi.OpenDefectService;

import java.util.List;

/**
 * @Author chencl
 * @Date 2024/4/19 10:15
 * @Version 1.0
 * @Description
 */
//@io.swagger.annotations.Api(tags = "第三方故障数据接口")
@org.springframework.web.bind.annotation.RestController
@org.springframework.web.bind.annotation.RequestMapping(value = Constant.OPEN_API_V1 + "/defect")
public class OpenApiDefectController {
    private final OpenDefectService openDefectService;

    public OpenApiDefectController(OpenDefectService openDefectService) {
        this.openDefectService = openDefectService;
    }

//    @io.swagger.annotations.ApiOperation("查询故障分页列表")
    @org.springframework.web.bind.annotation.PostMapping(value = "/page")
    public RestResp<PageInfo<StationDefectResVO>> page(@org.springframework.web.bind.annotation.RequestBody DefectQueryReqVO reqVo,
                                                       @javax.validation.constraints.Min(1) Integer pageNo,
                                                       @javax.validation.constraints.Min(1) @javax.validation.constraints.Max(9999) Integer pageSize){
        PageInfo<StationDefectResVO> pageInfo = openDefectService.page(reqVo, pageNo, pageSize);
        return RestResp.success(pageInfo);
    }
//    @io.swagger.annotations.ApiOperation("查询低效诊断故障分页列表")
    @org.springframework.web.bind.annotation.PostMapping(value = "/le/page")
    public RestResp<PageInfo<StationDefectResVO>> lePage(@org.springframework.web.bind.annotation.RequestBody DefectQueryReqVO reqVo,
                                                       @javax.validation.constraints.Min(1) Integer pageNo,
                                                       @javax.validation.constraints.Min(1) @javax.validation.constraints.Max(9999) Integer pageSize){
        reqVo.setFaultCategoryIn(FaultCategoryEnum.getFaultCategoryCollectionLE());
        PageInfo<StationDefectResVO> pageInfo = openDefectService.page(reqVo, pageNo, pageSize);
        return RestResp.success(pageInfo);
    }

//    @io.swagger.annotations.ApiOperation("查询低效诊断故障详情(曲线)")
    @org.springframework.web.bind.annotation.PostMapping(value = "/le/details")
    public RestResp<List<OpenApiDefectLeDetailResVO>> leDetails(@org.springframework.web.bind.annotation.RequestBody DefectQueryReqVO reqVo){
        reqVo.setFaultCategoryIn(FaultCategoryEnum.getFaultCategoryCollectionLE());
        List<OpenApiDefectLeDetailResVO> resVos = openDefectService.leDetails(reqVo);
        return RestResp.success(resVos);
    }
}
